/**
 * 
 */
package stc.skymobi.zookeeper;

import java.util.List;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.AsyncCallback.ACLCallback;
import org.apache.zookeeper.AsyncCallback.Children2Callback;
import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
import org.apache.zookeeper.AsyncCallback.DataCallback;
import org.apache.zookeeper.AsyncCallback.StatCallback;
import org.apache.zookeeper.AsyncCallback.StringCallback;
import org.apache.zookeeper.AsyncCallback.VoidCallback;
import org.apache.zookeeper.ZooKeeper.States;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Stat;

/**
 * @author hp
 *
 */
public class ZooKeeperAdapter implements ZooKeeperOperations {

	private	ZooKeeper	zk;
	
	/**
	 * @return the zk
	 */
	public ZooKeeper getZk() {
		return zk;
	}

	/**
	 * @param zk the zk to set
	 */
	public ZooKeeperOperations setZk(ZooKeeper zk) {
		this.zk = zk;
		return	this;
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#create(java.lang.String, byte[], java.util.List, org.apache.zookeeper.CreateMode)
	 */
	public String create(String path, byte[] data, List<ACL> acl,
			CreateMode createMode) throws KeeperException, InterruptedException {
		return zk.create(path, data, acl, createMode);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#create(java.lang.String, byte[], java.util.List, org.apache.zookeeper.CreateMode, org.apache.zookeeper.AsyncCallback.StringCallback, java.lang.Object)
	 */
	public void create(String path, byte[] data, List<ACL> acl,
			CreateMode createMode, StringCallback cb, Object ctx) {
		zk.create(path, data, acl, createMode, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#delete(java.lang.String, int)
	 */
	public void delete(String path, int version) throws InterruptedException,
			KeeperException {
		zk.delete(path, version);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#delete(java.lang.String, int, org.apache.zookeeper.AsyncCallback.VoidCallback, java.lang.Object)
	 */
	public void delete(String path, int version, VoidCallback cb, Object ctx) {
		zk.delete(path, version, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#exists(java.lang.String, org.apache.zookeeper.Watcher)
	 */
	public Stat exists(String path, Watcher watcher) throws KeeperException,
			InterruptedException {
		return zk.exists(path, watcher);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#exists(java.lang.String, boolean)
	 */
	public Stat exists(String path, boolean watch) throws KeeperException,
			InterruptedException {
		return zk.exists(path, watch);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#exists(java.lang.String, org.apache.zookeeper.Watcher, org.apache.zookeeper.AsyncCallback.StatCallback, java.lang.Object)
	 */
	public void exists(String path, Watcher watcher, StatCallback cb, Object ctx) {
		zk.exists(path, watcher, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#exists(java.lang.String, boolean, org.apache.zookeeper.AsyncCallback.StatCallback, java.lang.Object)
	 */
	public void exists(String path, boolean watch, StatCallback cb, Object ctx) {
		zk.exists(path, watch, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getACL(java.lang.String, org.apache.zookeeper.data.Stat)
	 */
	public List<ACL> getACL(String path, Stat stat) throws KeeperException,
			InterruptedException {
		return zk.getACL(path, stat);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getACL(java.lang.String, org.apache.zookeeper.data.Stat, org.apache.zookeeper.AsyncCallback.ACLCallback, java.lang.Object)
	 */
	public void getACL(String path, Stat stat, ACLCallback cb, Object ctx) {
		zk.getACL(path, stat, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, org.apache.zookeeper.Watcher)
	 */
	public List<String> getChildren(String path, Watcher watcher)
			throws KeeperException, InterruptedException {
		return zk.getChildren(path, watcher);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, boolean)
	 */
	public List<String> getChildren(String path, boolean watch)
			throws KeeperException, InterruptedException {
		return zk.getChildren(path, watch);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, org.apache.zookeeper.Watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback, java.lang.Object)
	 */
	public void getChildren(String path, Watcher watcher, ChildrenCallback cb,
			Object ctx) {
		zk.getChildren(path, watcher, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, boolean, org.apache.zookeeper.AsyncCallback.ChildrenCallback, java.lang.Object)
	 */
	public void getChildren(String path, boolean watch, ChildrenCallback cb,
			Object ctx) {
		zk.getChildren(path, watch, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, org.apache.zookeeper.Watcher, org.apache.zookeeper.data.Stat)
	 */
	public List<String> getChildren(String path, Watcher watcher, Stat stat)
			throws KeeperException, InterruptedException {
		return zk.getChildren(path, watcher, stat);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, boolean, org.apache.zookeeper.data.Stat)
	 */
	public List<String> getChildren(String path, boolean watch, Stat stat)
			throws KeeperException, InterruptedException {
		return zk.getChildren(path, watch, stat);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, org.apache.zookeeper.Watcher, org.apache.zookeeper.AsyncCallback.Children2Callback, java.lang.Object)
	 */
	public void getChildren(String path, Watcher watcher, Children2Callback cb,
			Object ctx) {
		zk.getChildren(path, watcher, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getChildren(java.lang.String, boolean, org.apache.zookeeper.AsyncCallback.Children2Callback, java.lang.Object)
	 */
	public void getChildren(String path, boolean watch, Children2Callback cb,
			Object ctx) {
		zk.getChildren(path, watch, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getData(java.lang.String, org.apache.zookeeper.Watcher, org.apache.zookeeper.data.Stat)
	 */
	public byte[] getData(String path, Watcher watcher, Stat stat)
			throws KeeperException, InterruptedException {
		return zk.getData(path, watcher, stat);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getData(java.lang.String, boolean, org.apache.zookeeper.data.Stat)
	 */
	public byte[] getData(String path, boolean watch, Stat stat)
			throws KeeperException, InterruptedException {
		return zk.getData(path, watch, stat);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getData(java.lang.String, org.apache.zookeeper.Watcher, org.apache.zookeeper.AsyncCallback.DataCallback, java.lang.Object)
	 */
	public void getData(String path, Watcher watcher, DataCallback cb,
			Object ctx) {
		zk.getData(path, watcher, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#getData(java.lang.String, boolean, org.apache.zookeeper.AsyncCallback.DataCallback, java.lang.Object)
	 */
	public void getData(String path, boolean watch, DataCallback cb, Object ctx) {
		zk.getData(path, watch, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#register(org.apache.zookeeper.Watcher)
	 */
	public void register(Watcher watcher) {
		zk.register(watcher);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#setACL(java.lang.String, java.util.List, int)
	 */
	public Stat setACL(String path, List<ACL> acl, int version)
			throws KeeperException, InterruptedException {
		return zk.setACL(path, acl, version);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#setACL(java.lang.String, java.util.List, int, org.apache.zookeeper.AsyncCallback.StatCallback, java.lang.Object)
	 */
	public void setACL(String path, List<ACL> acl, int version,
			StatCallback cb, Object ctx) {
		zk.setACL(path, acl, version, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#setData(java.lang.String, byte[], int)
	 */
	public Stat setData(String path, byte[] data, int version)
			throws KeeperException, InterruptedException {
		return zk.setData(path, data, version);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#setData(java.lang.String, byte[], int, org.apache.zookeeper.AsyncCallback.StatCallback, java.lang.Object)
	 */
	public void setData(String path, byte[] data, int version, StatCallback cb,
			Object ctx) {
		zk.setData(path, data, version, cb, ctx);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.distributed.ZooKeeperOperations#sync(java.lang.String, org.apache.zookeeper.AsyncCallback.VoidCallback, java.lang.Object)
	 */
	public void sync(String path, VoidCallback cb, Object ctx) {
		zk.sync(path, cb, ctx);
	}

	public States getState() {
		return zk.getState();
	}

}
